package com.awifi.demo.controller;

import com.awifi.demo.consumer.KafkaConsumerExample;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/8/7 15:13
 */
@Slf4j
@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    @Autowired
    private KafkaConsumerExample kafkaConsumer;

    @PostMapping("/test")
    public void kafkaTest(String message) {
        kafkaTemplate.send("demo",message);
    }


    @PostMapping("/consumer")
    public boolean kafkaConsumer() {
        kafkaConsumer.run();
        return true;
    }
}
